﻿@model DLULearningNetwork.ViewModels.ListFilesViewModel
@using DLULearningNetwork.Libs
@{    
    List<DLULearningNetworkModel.File> files = Model.Files;
}
<div id="loading" class="loading" style="width: 200px; height: 220px;">
</div>
<table class="tbl1" cellspacing="0" style="margin-top: 10px;">
    <tr>
        <th style="width: 290px;">
            Tên file
        </th>
        <th>
            Lĩnh vực
        </th>
        <th>
            Người đăng
        </th>
        <th>
            Ngày đăng
        </th>
        <th>
            Dung lượng
        </th>
        <th>
        </th>
    </tr>
    <tbody>
        @for (int i = 0; i < files.Count; i++)
        {                        
            <tr @if (i % 2 != 0)
                {
                    string str = "class=odd"; @str;
                }>
                <td title="@files[i].FileName_s">
                    @DLULearningNetwork.Libs.StringHelper.ShortcutContent(files[i].FileName_s, 35)
                </td>
                <td>@files[i].Category.Name_s
                </td>
                <td>
                    <a href="/UserPage/UserHome/@files[i].Account.Nickname_s">@DLULearningNetwork.Libs.StringHelper.ShortcutContent(files[i].Account.Nickname_s, 11)</a>
                </td>
                <td>@String.Format("{0:dd/MM/yyyy}", files[i].CreateDate_dt)
                </td>
                <td>@String.Format("{0:#,#}", files[i].Size_f) KBs
                </td>
                <td>
                    @if (DLULearningNetwork.Controllers.FrontEndBaseController.LoginUser.AccountID_u == files[i].AccountID_u)
                    {
                        @Html.ActionLink("Tải về", "Download", new { id = @files[i].FileID_u })
                    }
                    else
                    {
                        switch (files[i].Share_s.ToLower().Trim())
                        {
                            case "private":
                                if (DLULearningNetwork.Controllers.FrontEndBaseController.LoginUser.AccountID_u == files[i].AccountID_u)
                                {
                        @Html.ActionLink("Tải về", "Download", new { id = @files[i].FileID_u })
                                }
                                else
                                {
                        <span style="color: #ff0000;">Cá nhân</span>
                                }

                                break;
                            case "friends":
                                if (DLULearningNetworkModel.Friend.Single(DLULearningNetwork.Controllers.FrontEndBaseController.LoginUser.AccountID_u, files[i].AccountID_u) != null)
                                {
                        @Html.ActionLink("Tải về", "Download", new { id = @files[i].FileID_u })
                                }
                                else
                                {
                        <span style="color: #ff0000;">Bạn bè</span>
                                }

                                break;
                            default:
                        @Html.ActionLink("Tải về", "Download", new { id = @files[i].FileID_u })   
                   break;
                        }
                    }
                </td>
            </tr>
        }
    </tbody>
</table>
<div class="pagination pagination-left" style="margin-left: 3px;">
    <ul class="pager">
        @Html.Partial("UCPager2", new DLULearningNetwork.ViewModels.PagerViewModel2(Model.TotalItems, Constants.DEFAULT_PAGESIZE, Constants.DEFAULT_FILES_PERPAGE,
                    Model.CurrentPage))
    </ul>
</div>
